package Servlet;

import java.io.IOException;
import java.util.HashMap;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import vo.Book;
public class AddServlet extends HttpServlet {
	public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
		request.setCharacterEncoding("utf-8");
		HttpSession session=request.getSession();		
		HashMap books=(HashMap)session.getAttribute("books");
		//获取提交的内容
		String bookno=request.getParameter("bookno");
		String bookname=request.getParameter("bookname");
		String strBookprice=request.getParameter("bookprice");
		String strBooknumber=request.getParameter("booknumber");
//		System.out.print(bookno);
//		System.out.print(bookname);
//		System.out.print(strBookprice);
//		System.out.print(strBooknumber);
		//存入购物车
		Book book=new Book();
		book.setBookno(bookno);
		book.setBookname(bookname);
		float bookprice=Float.parseFloat(strBookprice);
		book.setBookPrice(bookprice);
		//System.out.println(strBookprice);
		int booknumber=Integer.parseInt(strBooknumber);
		//System.out.println(strBooknumber);
		book.setBooknumber(booknumber);
		books.put("bookno",book);
		//总钱数增加
		/*//float money=(Float)session.getAttribute("money");
		float money=(float)bookprice*booknumber;
		System.out.print(money);
		ession.setAttribute("money", money);
		*/
		response.sendRedirect("/Proj3/showCart.jsp");
		
	}
}
